package com.ayf.payment.game.api.service;

import com.ayf.payment.game.api.dto.*;
import com.ayf.payment.game.api.dto.criteria.LowerMerchantCriteria;
import com.ayf.payment.game.api.dto.criteria.MerchantCriteria;
import com.ayf.payment.game.api.dto.platform.MerchantAccountQueryDTO;
import com.ayf.payment.game.api.dto.platform.MerchantSettleDTO;
import com.ayf.payment.game.api.dto.platform.criteria.MerchantAccountCriteria;
import com.ayf.payment.game.api.dto.platform.criteria.MerchantAccountPageCriteria;
import com.ayf.payment.game.api.entity.Merchant;
import com.ayf.payment.game.api.entity.MerchantConfig;
import com.ayf.payment.game.api.entity.MerchantSettleRateCustom;
import org.springframework.transaction.annotation.Transactional;

import java.beans.Transient;
import java.util.List;

public interface MerchantService {

    /**
     * 查询出商户信息
     *
     * @param merchant
     * @return
     */
    MerchantDTO selectOne(Merchant merchant);

    Merchant find(Integer id);

    /**
     * 更新商户信息
     *
     * @param merchant
     * @return
     */
    boolean update(Merchant merchant);

    /**
     * 解绑手机号
     *
     * @param merchantId
     * @return
     */
    boolean untieMobile(Integer merchantId);

    /**
     * 商户注册
     *
     * @param merchantCriteria
     * @return
     */
    @Transactional
    boolean register(MerchantCriteria merchantCriteria);

    /**
     * 商户登录
     *
     * @param merchantCriteria
     * @return
     */
    MerchantLoginDTO login(MerchantCriteria merchantCriteria);

    /**
     * 修改商户密码
     *
     * @param merchantCriteria
     * @return
     */
    boolean updatePassword(MerchantCriteria merchantCriteria);

    /**
     * 忘记密码
     *
     * @param merchantCriteria
     * @return
     */
    boolean resetPassword(MerchantCriteria merchantCriteria);

    /**
     * 修改商户支付密码
     *
     * @param merchantCriteria
     * @return
     */
    boolean updatePayPassword(MerchantCriteria merchantCriteria);

    /**
     * 设置商户支付密码
     *
     * @param merchantCriteria
     * @return
     */
    boolean setPayPassword(MerchantCriteria merchantCriteria);

    /**
     * 查询出所有商户
     *
     * @return
     */
    List<MerchantDTO> selectAll(MerchantCriteria merchantCriteria);

    /**
     * 查询出待审核商户
     *
     * @return
     */
    List<AuditedMerchantDTO> selectAuditedMerchant();

    /**
     * 更新商户类型
     *
     * @param merchantCriteria
     * @return
     */
    @Transient
    boolean updateMerchantType(MerchantCriteria merchantCriteria);

    /**
     * 删除商户
     *
     * @param merchantId
     * @return
     */
    @Transient
    boolean deleteMerchant(Integer merchantId);

    /**
     * 添加下级商户
     *
     * @param lowerMerchantCriteria
     * @return
     */
    @Transactional
    boolean insertLowerMerchant(LowerMerchantCriteria lowerMerchantCriteria);

    /**
     * 查询出代理商下级商户id集合
     *
     * @param merchantId
     * @return
     */
    List<Integer> selectIds(Integer merchantId);

    /**
     * 查询出代理商id集合
     *
     * @return
     */
    List<Integer> selectProxyIds();

    /**
     * 查询出所有下级商户
     *
     * @return
     */
    List<LowerMerchantDTO> selectAllLower(LowerMerchantCriteria lower);

    /**
     * 查询出商户详细信息
     *
     * @param merchantId
     * @return
     */
    LowerMerchantCriteria selectMerchantInfo(Integer merchantId);

    /**
     * 更新商户详细信息
     *
     * @param lower
     * @return
     */
    boolean updateMerchantInfo(LowerMerchantCriteria lower);

    /**
     * 更新商户费率分组信息
     *
     * @param lower
     * @return
     */
    @Transient
    boolean updateMerchantGroup(LowerMerchantCriteria lower);

    /**
     * 查询出商户费率信息集合
     *
     * @param merchantId
     * @return
     */
    List<SettleRateInfoDTO> selectRateInfo(Integer merchantId);

    /**
     * 更改商户结算产品状态
     *
     * @param rateCustom
     * @return
     */
    boolean updateProductStatus(MerchantSettleRateCustom rateCustom);

    /**
     * 查询出商户详细配置信息
     *
     * @param merchantId
     * @return
     */
    MerchantDTO selectMerchantDTO(Integer merchantId);

    /**
     * 查询商户相关配制信息
     * @param merchantId
     * @return
     */
    MerchantCommonDTO getMerchantCommon(Integer merchantId);

    /**
     * 设置普通商户为下级商户
     *
     * @param lowerMerchantCriteria
     * @return
     */
    @Transactional
    boolean setLower(LowerMerchantCriteria lowerMerchantCriteria);

    boolean checkPayPassword(Integer merchantId, String payPassword);

    void upateMerchantLevel(Integer merchantId,Integer level);


    List<MerchantSettleDTO> getSettleList(Integer date, Integer merchantId);

    MerchantAccountQueryDTO countMerchantAccount(MerchantAccountCriteria merchantAccountCriteria);

    List<MerchantAccountDTO> merchantAccountList(MerchantAccountPageCriteria merchantAccountPageCriteria);

    boolean updateMerchantPwd(MerchantDTO dto);

    boolean updateMerchantAndMerchantConfig(Merchant merchant, MerchantConfig merchantConfig);
}
